package bean.caculate;

import bean.actor.BaseActor;

public abstract class AbstractCaculator {
    private AbstractCaculator next;

    public BaseActor process(BaseActor baseActor) {
        if(canCaculate(baseActor)) {
            return handle(baseActor);
        } else if (next != null) {
            return next.process(baseActor);
        }
        return baseActor;
    }

    public void setNext(AbstractCaculator next) {
        this.next = next;
    }

    abstract boolean canCaculate(BaseActor baseActor);
    abstract BaseActor handle(BaseActor baseActor);
}
